Optimal. Leaf size=59 \[ \frac {x}{b}-\frac {2 a \text {ArcTan}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{\sqrt {a-b} b \sqrt {a+b} d} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.04, antiderivative size = 59, normalized size of antiderivative = 1.00, number of steps
used = 3, number of rules used = 3, integrand size = 19, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.158, Rules used = {2814, 2738,
211} \begin {gather*} \frac {x}{b}-\frac {2 a \text {ArcTan}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{b d \sqrt {a-b} \sqrt {a+b}} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 211
Rule 2738
Rule 2814
Rubi steps
\begin {align*} \int \frac {\cos (c+d x)}{a+b \cos (c+d x)} \, dx &=\frac {x}{b}-\frac {a \int \frac {1}{a+b \cos (c+d x)} \, dx}{b}\\ &=\frac {x}{b}-\frac {(2 a) \text {Subst}\left (\int \frac {1}{a+b+(a-b) x^2} \, dx,x,\tan \left (\frac {1}{2} (c+d x)\right )\right )}{b d}\\ &=\frac {x}{b}-\frac {2 a \tan ^{-1}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{\sqrt {a-b} b \sqrt {a+b} d}\\ \end {align*}
________________________________________________________________________________________
Mathematica [A]
time = 0.08, size = 58, normalized size = 0.98 \begin {gather*} \frac {c+d x+\frac {2 a \tanh ^{-1}\left (\frac {(a-b) \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {-a^2+b^2}}\right )}{\sqrt {-a^2+b^2}}}{b d} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.12, size = 65, normalized size = 1.10
method | result | size |
derivativedivides | \(\frac {\frac {2 \arctan \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{b}-\frac {2 a \arctan \left (\frac {\tan \left (\frac {d x}{2}+\frac {c}{2}\right ) \left (a -b \right )}{\sqrt {\left (a -b \right ) \left (a +b \right )}}\right )}{b \sqrt {\left (a -b \right ) \left (a +b \right )}}}{d}\) | \(65\) |
default | \(\frac {\frac {2 \arctan \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{b}-\frac {2 a \arctan \left (\frac {\tan \left (\frac {d x}{2}+\frac {c}{2}\right ) \left (a -b \right )}{\sqrt {\left (a -b \right ) \left (a +b \right )}}\right )}{b \sqrt {\left (a -b \right ) \left (a +b \right )}}}{d}\) | \(65\) |
risch | \(\frac {x}{b}-\frac {a \ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {-i a^{2}+i b^{2}+a \sqrt {-a^{2}+b^{2}}}{\sqrt {-a^{2}+b^{2}}\, b}\right )}{\sqrt {-a^{2}+b^{2}}\, d b}+\frac {a \ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {i a^{2}-i b^{2}+a \sqrt {-a^{2}+b^{2}}}{b \sqrt {-a^{2}+b^{2}}}\right )}{\sqrt {-a^{2}+b^{2}}\, d b}\) | \(150\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F(-2)]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Exception raised: ValueError} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [A]
time = 0.43, size = 223, normalized size = 3.78 \begin {gather*} \left [\frac {2 \, {\left (a^{2} - b^{2}\right )} d x - \sqrt {-a^{2} + b^{2}} a \log \left (\frac {2 \, a b \cos \left (d x + c\right ) + {\left (2 \, a^{2} - b^{2}\right )} \cos \left (d x + c\right )^{2} - 2 \, \sqrt {-a^{2} + b^{2}} {\left (a \cos \left (d x + c\right ) + b\right )} \sin \left (d x + c\right ) - a^{2} + 2 \, b^{2}}{b^{2} \cos \left (d x + c\right )^{2} + 2 \, a b \cos \left (d x + c\right ) + a^{2}}\right )}{2 \, {\left (a^{2} b - b^{3}\right )} d}, \frac {{\left (a^{2} - b^{2}\right )} d x - \sqrt {a^{2} - b^{2}} a \arctan \left (-\frac {a \cos \left (d x + c\right ) + b}{\sqrt {a^{2} - b^{2}} \sin \left (d x + c\right )}\right )}{{\left (a^{2} b - b^{3}\right )} d}\right ] \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [B] Leaf count of result is larger than twice the leaf count of optimal. 320 vs.
\(2 (48) = 96\).
time = 11.93, size = 320, normalized size = 5.42 \begin {gather*} \begin {cases} \tilde {\infty } x & \text {for}\: a = 0 \wedge b = 0 \wedge d = 0 \\\frac {x}{b} + \frac {1}{b d \tan {\left (\frac {c}{2} + \frac {d x}{2} \right )}} & \text {for}\: a = - b \\\frac {\sin {\left (c + d x \right )}}{a d} & \text {for}\: b = 0 \\\frac {x \cos {\left (c \right )}}{a + b \cos {\left (c \right )}} & \text {for}\: d = 0 \\\frac {x}{b} - \frac {\tan {\left (\frac {c}{2} + \frac {d x}{2} \right )}}{b d} & \text {for}\: a = b \\\frac {a d x \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}}}{a b d \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}} - b^{2} d \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}}} - \frac {a \log {\left (- \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}} + \tan {\left (\frac {c}{2} + \frac {d x}{2} \right )} \right )}}{a b d \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}} - b^{2} d \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}}} + \frac {a \log {\left (\sqrt {- \frac {a}{a - b} - \frac {b}{a - b}} + \tan {\left (\frac {c}{2} + \frac {d x}{2} \right )} \right )}}{a b d \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}} - b^{2} d \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}}} - \frac {b d x \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}}}{a b d \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}} - b^{2} d \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}}} & \text {otherwise} \end {cases} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [B] Leaf count of result is larger than twice the leaf count of optimal. 240 vs.
\(2 (50) = 100\).
time = 0.47, size = 240, normalized size = 4.07 \begin {gather*} -\frac {\frac {{\left (\sqrt {a^{2} - b^{2}} {\left (2 \, a - b\right )} {\left | a - b \right |} + \sqrt {a^{2} - b^{2}} {\left | a - b \right |} {\left | b \right |}\right )} {\left (\pi \left \lfloor \frac {d x + c}{2 \, \pi } + \frac {1}{2} \right \rfloor + \arctan \left (\frac {2 \, \sqrt {\frac {1}{2}} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )}{\sqrt {\frac {2 \, a + \sqrt {-4 \, {\left (a + b\right )} {\left (a - b\right )} + 4 \, a^{2}}}{a - b}}}\right )\right )}}{{\left (a^{2} - 2 \, a b + b^{2}\right )} b^{2} + {\left (a^{3} - 2 \, a^{2} b + a b^{2}\right )} {\left | b \right |}} + \frac {{\left (\pi \left \lfloor \frac {d x + c}{2 \, \pi } + \frac {1}{2} \right \rfloor + \arctan \left (\frac {2 \, \sqrt {\frac {1}{2}} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )}{\sqrt {\frac {2 \, a - \sqrt {-4 \, {\left (a + b\right )} {\left (a - b\right )} + 4 \, a^{2}}}{a - b}}}\right )\right )} {\left (2 \, a - b - {\left | b \right |}\right )}}{b^{2} - a {\left | b \right |}}}{d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 0.78, size = 99, normalized size = 1.68 \begin {gather*} \frac {2\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{b\,d}+\frac {2\,a\,\mathrm {atanh}\left (\frac {a\,\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )-b\,\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\sqrt {b^2-a^2}}\right )}{b\,d\,\sqrt {b^2-a^2}} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________